import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";

export const Layout = () => import("@/layout/index.vue");
import approval from './modules/approval'
import attendance from './modules/attendance'
import department from './modules/department'
import employee from './modules/employee'
import permission from './modules/permission'
import role from './modules/role'
import salary from './modules/salary'
import social from './modules/social'
// 静态路由
export const constantRoutes: RouteRecordRaw[] = [
  {
    path: '/login',
    component: () => import('@/views/login/index.vue'),
    meta:{hidden: true}
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index.vue'),
      name: 'Dashboard',
      meta: { title: '首页', icon: 'dashboard' }
    }]
  },
  {
    path:'/approval',
    component:Layout,
    children:[{
      path:'',
      component:()=>import('@/views/approval/index.vue')
    }]
  },
  // approval,
  // attendance,
  // department,
  // employee,
  // permission,
  // role,
  // salary ,
  // social,
  {
    path: '/404',
    component: () => import('@/views/404.vue'),
    meta:{hidden: true}
  }
  // 404 page must be placed at the end !!!
];
/**动态路由 */
export const asyncRouter = [
  
]
/**
 * 创建路由
 */
const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes as RouteRecordRaw[],
  // 刷新时，滚动条位置还原
  scrollBehavior: () => ({ left: 0, top: 0 }),
});

/**
 * 重置路由
 */
export function resetRouter() {
  router.replace({ path: "/login" });
  location.reload();
}

export default router;
